package org.wu.framework.authorization.platform.infrastructure.persistence;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.wu.framework.authorization.platform.infrastructure.converter.SysDictionaryConverter;
import org.wu.framework.authorization.platform.infrastructure.entity.SysDictionaryDO;
import org.wu.framework.authorization.platform.domain.model.sys.dictionary.SysDictionary;
import org.wu.framework.authorization.platform.domain.model.sys.dictionary.SysDictionaryRepository;
import org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyInfrastructurePersistence;
import org.wu.framework.lazy.orm.database.lambda.stream.lambda.LazyLambdaStream;
import org.wu.framework.lazy.orm.database.lambda.stream.wrapper.LazyWrappers;
import org.wu.framework.lazy.orm.web.plus.AbstractLazyCrudRepository;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.response.ResultFactory;

import java.util.List;

/**
 * describe
 *
 * @author Jia wei Wu
 * @date 2023/05/17 11:19 晚上
 * @see DefaultDDDLazyInfrastructurePersistence
 **/
@Repository
public class SysDictionaryRepositoryImpl extends AbstractLazyCrudRepository<SysDictionaryDO, SysDictionary, Integer> implements SysDictionaryRepository {

    @Autowired
    LazyLambdaStream lazyLambdaStream;


    /**
     * describe 新增
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysDictionary> story(SysDictionary sysDictionary) {
        SysDictionaryDO sysDictionaryDO = SysDictionaryConverter.fromDictionary(sysDictionary);
        lazyLambdaStream.upsert(sysDictionaryDO);
        return ResultFactory.successOf();
    }

    /**
     * describe 查询单个
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysDictionary> findOne(SysDictionary sysDictionary) {
        SysDictionaryDO sysDictionaryDO = SysDictionaryConverter.fromDictionary(sysDictionary);
        SysDictionary sysDictionaryOne = lazyLambdaStream.selectOne(LazyWrappers.lambdaWrapperBean(sysDictionaryDO), SysDictionary.class);
        return ResultFactory.successOf(sysDictionaryOne);
    }

    /**
     * describe 查询多个
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<List<SysDictionary>> findList(SysDictionary sysDictionary) {
        SysDictionaryDO sysDictionaryDO = SysDictionaryConverter.fromDictionary(sysDictionary);
        List<SysDictionary> sysDictionaryList = lazyLambdaStream.selectList(LazyWrappers.lambdaWrapperBean(sysDictionaryDO), SysDictionary.class);
        return ResultFactory.successOf(sysDictionaryList);
    }

    /**
     * describe 删除
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysDictionary> delete(SysDictionary sysDictionary) {
        SysDictionaryDO sysDictionaryDO = SysDictionaryConverter.fromDictionary(sysDictionary);
        //  lazyLambdaStream.remove(sysDictionaryDO);
        return ResultFactory.successOf();
    }

}